package codeComposition;

public class ListItemElement extends ObjectElement {
	static int i = 0;
	private String index;
	Element e;
	
	public ListItemElement(Element e, String num){
		super(String.valueOf(i));
		this.e = e;
		this.index = num;
	}
	public ListItemElement(String e, String num){
		super(String.valueOf(i));
		this.e = new ReferenceElement(e);
		this.index = num;
	}
	
	public String toString(){
		if(e instanceof ExpressionElement){
			return ((ExpressionElement)e).getRawString() + "[" + index + "]";
		}else if(e instanceof ObjectElement){
			return ((ObjectElement)e).toString() + "[" + index + "]";
		}else return "unsupport element type in listelement tostring()";
	}
}
